package com.shuang.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.shuang.pojo.ExtendDbGoodsFormat;
import com.shuang.service.DbGoodsFormatService;

@Controller
@RequestMapping("/format")
public class DbGoodsFormatHanlder {
	@Resource(name="dbGoodsFormatService")
	private DbGoodsFormatService dbGoodsFormatService;
	
	@RequestMapping("/findFormatById")
	@ResponseBody
	public List<ExtendDbGoodsFormat>  findFormatById(@RequestParam(value="id")Long cId){
		return  dbGoodsFormatService.findFormatById(cId);
	}
	
	@RequestMapping("/saveFormatParam/{cId}")
	@ResponseBody
	public Map<String ,Object> saveFormatParam(@PathVariable Long cId,String paramData) throws Exception{
		if(cId==null||paramData==null||paramData==""){
			 Map<String, Object> map = new HashMap<String, Object>();
			 map.put("status", 403);
			 return map;
		}
		return dbGoodsFormatService.saveFormatParam(cId,paramData);
	}
	
	@RequestMapping("/updateFormatParam/{gfId}")
	@ResponseBody
	public Map<String ,Object> updateFormatParam(@PathVariable Long gfId,String paramData) throws Exception{
		if(gfId==null||paramData==null||paramData==""){
			 Map<String, Object> map = new HashMap<String, Object>();
			 map.put("status", 403);
			 return map;
		}
		return dbGoodsFormatService.updateFormatParam(gfId,paramData);
	}
	
	@RequestMapping("/selectFormatInfoByCid/{cId}")
	@ResponseBody
	public Map<String,Object> selectFormatInfoByCid(@PathVariable Long cId){
		if(cId==null){
			Map<String,Object> map=new HashMap<String, Object>();
			map.put("status", 403);
			return map;
		}
		return dbGoodsFormatService.selectFormatInfoByCid(cId);
		
	}
}
